<template>
	<div>
		<div class="table-wrap">
			<el-table :data="tableData" border style="width: 100%">
				<el-table-column prop="realname" label="教师姓名" align="center"></el-table-column>
				<el-table-column prop="score" label="积分" align="center" sortable></el-table-column>
				<el-table-column prop="type" label="积分状态" align="center">
					<template slot-scope="scope">
						{{scope.row.type | scoreTypeMap}}
					</template>
				</el-table-column>
				<el-table-column prop="desc" label="积分描述" align="center"></el-table-column>
				<el-table-column prop="create_time" label="创建时间" align="center" sortable></el-table-column>
			</el-table>
		</div>

		<common-pagination v-if='total > 10' :total="total" :size="searchData.size" @size-change="handelPagesizeChange"
			@page-change="handlePageChange"></common-pagination>
	</div>
</template>

<script>
	import CommonPagination from '@/components/CommonPagination';
	import {
		teacherScoreList
	} from '@/api/score';
	export default {
		name: 'messagepush',
		data() {
			return {
				tableData: [],
				total: 0,
				searchData: {
					page: 1, //第几页
					size: 10,
				},

			}
		},

		mounted() {
			this.getScoreList();
		},

		methods: {
			async getScoreList() {
				const {
					status,
					data
				} = await teacherScoreList(this.searchData);
				if (status !== 200) return
				if (data.code == 200) {
					this.tableData = data?.data?.list || [];
					this.total = data?.data?.total || 0;
				} else {
					this.tableData = [];
					this.total = 0
					this.$message.warning(data?.message || '获取失败');
				}
			},
			
			handelPagesizeChange(size) {
				this.searchData.size = size;
				this.getScoreList();
			},
			handlePageChange(page) {
				this.searchData.page = page;
				this.getScoreList();
			}
		},

		components: {
			CommonPagination
		}
	}
</script>

<style lang="less" scoped>
	@import '~@/assets/styles/variables.less';

	.header {
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}
	.dialog-body-wrap {
		text-align: center;

		.input-wrap {
			display: flex;
			align-items: center;
			margin-bottom: 20px;

			label {
				margin-right: 30px;
				width: 110px;
				text-align: right;
			}

			.recharge_money_input,
			.recharge_amount_input {
				width: 194px;
			}
		}
	}
</style>